home *** CD-ROM | disk | FTP | other *** search
/ GFX Sensations 1 / Graphic Sensations - Volume 1.iso / tools / amiga / 3d_tools / irit40s.lha / Irit / grapdrvs / draw_crv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-30  |  2.1 KB  |  63 lines

  1. /*****************************************************************************
  2. *   Default curve drawing routine common to graphics drivers.             *
  3. *                                         *
  4. * Written by:  Gershon Elber                Ver 0.1, June 1993.  *
  5. *****************************************************************************/
  6.  
  7. #include "irit_sm.h"
  8. #include "iritprsr.h"
  9. #include "allocate.h"
  10. #include "ip_cnvrt.h"
  11. #include "cagd_lib.h"
  12. #include "iritgrap.h"
  13.  
  14. /****************************************************************************
  15. * Draw a single Curve object using current modes and transformations.        *
  16. *   Curve must be with either E3 or P3 point type and must be NURB.        *
  17. *   Control points in SGI's format must be found in "_ctlpoints" attribute. *
  18. ****************************************************************************/
  19. void IGDrawCurve(IPObjectStruct *PObj)
  20. {
  21.     IPObjectStruct *PObjPolylines, *PObjCtlPolys;
  22.  
  23.     if ((PObjPolylines = AttrGetObjectObjAttrib(PObj, "_isoline")) == NULL) {
  24.     CagdCrvStruct *Crv,
  25.         *Crvs = PObj -> U.Crvs;
  26.     IPPolygonStruct *PPolyline;
  27.  
  28.     PObjPolylines = IPAllocObject("", IP_OBJ_POLY, NULL);
  29.     PObjPolylines -> Attrs = AttrCopyAttributes(PObj -> Attrs);
  30.     IP_SET_POLYLINE_OBJ(PObjPolylines);
  31.     for (Crv = Crvs; Crv != NULL; Crv = Crv -> Pnext) {
  32.         PPolyline = IritCurve2Polylines(Crv, IGGlblSamplesPerCurve);
  33.  
  34.         PPolyline -> Pnext = PObjPolylines -> U.Pl;
  35.         PObjPolylines -> U.Pl = PPolyline;
  36.     }
  37.     AttrSetObjectObjAttrib(PObj, "_isoline", PObjPolylines);
  38.     }
  39.     IGDrawPoly(PObjPolylines);
  40.  
  41.     if (IGGlblDrawSurfaceMesh) {
  42.     if ((PObjPolylines = AttrGetObjectObjAttrib(PObj, "_ctlpoly"))
  43.                                 == NULL) {
  44.         CagdCrvStruct *Crv,
  45.         *Crvs = PObj -> U.Crvs;
  46.         IPPolygonStruct *PCtlPoly;
  47.  
  48.         PObjCtlPolys = IPAllocObject("", IP_OBJ_POLY, NULL);
  49.         PObjCtlPolys -> Attrs = AttrCopyAttributes(PObj -> Attrs);
  50.         IP_SET_POLYLINE_OBJ(PObjCtlPolys);
  51.         for (Crv = Crvs; Crv != NULL; Crv = Crv -> Pnext) {
  52.         PCtlPoly = IritCurve2CtlPoly(Crv);
  53.  
  54.         PCtlPoly -> Pnext = PObjCtlPolys -> U.Pl;
  55.         PObjCtlPolys -> U.Pl = PCtlPoly;
  56.         }
  57.         AttrSetObjectObjAttrib(PObj, "_ctlpoly", PObjCtlPolys);
  58.     }
  59.  
  60.     IGDrawPoly(AttrGetObjectObjAttrib(PObj, "_ctlpoly"));
  61.     }
  62. }
  63.